export class ProtoConfig {

    public static PB_MESSAGE: string = "PB_MESSAGE";
    public static req_login: string = "req_login";
    public static resp_login: string = "resp_login";
    public static resp_error_code: string = "resp_error_code";
    public static struct_user_sys_info: string = "struct_user_sys_info";
    public static struct_user_info:string = "struct_user_info";
    public static req_register: string = "req_register";
    public static resp_register: string = "resp_register";

    private static requestProtoMap: Map<number, string> = new Map<number, string>().
        set(1, ProtoConfig.req_login).
        set(3, ProtoConfig.req_register)


    private static responseMap: Map<number, string> = new Map<number, string>().
        set(1, ProtoConfig.resp_login).
        set(2, ProtoConfig.resp_error_code).
        set(3, ProtoConfig.resp_register)


    public static getProtoReqName(protoType: number): string {
        return ProtoConfig.requestProtoMap.get(protoType);
    }

    public static getProtoRespName(protoType: number): string {
        return ProtoConfig.responseMap.get(protoType);
    }

    public static getProtoRequestType(protoName: string) {
        let protoType: number = 1;
        ProtoConfig.requestProtoMap.forEach((value: string, key: number) => {
            if (value == protoName) {
                protoType = key;
                return;
            }
        });
        return protoType;
    }

    public static getProtoResponeseType(protoName: string) {
        let protoType: number = 1;
        ProtoConfig.responseMap.forEach((value: string, key: number) => {
            if (value == protoName) {
                protoType = key;
                return;
            }
        });
        return protoType;
    }

    // public static getProtoType(protoName: string) {
    //     let protoType: number = 1;
    //     ProtoConfig.protoMap.forEach((value: string, key: number) => {
    //         if (value == protoName) {
    //             protoType = key;
    //         }
    //     });
    //     return protoType;
    // }

}
